#include <algorithm>
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <ostream>
#include <sstream>
#include <string>

#define lld long long // long long 的printf 占位符是lld
#define ENDL '\n'     // 将 endl 替换为 \n 取消缓冲区

const long long MAX_ = 1e9;

using std::cin;
using std::cout;
using std::endl;
using std::string;
const int MOD = 1e9 + 7;
lld dp[1009];
void mul(lld i, lld pos) {
  dp[i] = ((i - pos + 1) % MOD * dp[pos] % MOD) % MOD;
}
void solve() {
  //
  memset(dp, 0, sizeof(dp));
  lld ans = 0;
  string x;
  cin >> x;
  int len = x.size();
  int pos = -1;
  dp[0] = 0;

  // 1011 dp[0]=1,dp[1]=1,dp[2]=
  // 找到第一个1 初始化
  for (size_t i = 0; i < len; ++i) {
    if (x[i] == '1') {
      pos = i;
      dp[i] = 1;
      break;
    }
  }

  if (pos == -1) {
    cout << 0 << ENDL;
    return;
  }

  for (size_t i = pos + 1; i < len; ++i) {
    // cout << "i is " << i << ENDL;
    if (x[i] == '0')
      dp[i] = dp[i - 1];
    if (x[i] == '1') {
      mul(i, pos);
      pos = i;
    }
  }
  cout << dp[len - 1] << ENDL;
}

int main() {
  int T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
}